package dcedit.util;

// Import Java SDK Classes
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.awt.Insets;
import javax.swing.JToggleButton;
import javax.swing.ImageIcon;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;

/** DynamicOmniToggleButton class */
public class DynamicOmniToggleButton extends JToggleButton {
    /** Serializable constant */
   public static final long serialVersionUID = 1289514851234L;

   /** Default image field */
   private ImageIcon defaultImage;

   /** Mouse-hover image field */
   private ImageIcon hoverImage;

   /** Button selected image field */
   private ImageIcon selectImage;

   /** Button disabled image field */
   private ImageIcon disableImage;

   /** Constructor */
   public DynamicOmniToggleButton(String defaultImg, String hoverImg, String selectImg, String disableImg) {
      this(new File(defaultImg), new File(hoverImg), new File(selectImg), new File(disableImg));
   } // END constructor

   /** Constructor */
   public DynamicOmniToggleButton(File defaultImg, File hoverImg, File selectImg, File disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != selectImg) {
            selectImage = new ImageIcon(ImageIO.read(selectImg));
            this.setSelectedIcon(selectImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniToggleButton(InputStream defaultImg, InputStream hoverImg, InputStream selectImg, InputStream disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != selectImg) {
            selectImage = new ImageIcon(ImageIO.read(selectImg));
            this.setSelectedIcon(selectImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniToggleButton(ImageInputStream defaultImg, ImageInputStream hoverImg, ImageInputStream selectImg, ImageInputStream disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != selectImg) {
            selectImage = new ImageIcon(ImageIO.read(selectImg));
            this.setSelectedIcon(selectImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public DynamicOmniToggleButton(URL defaultImg, URL hoverImg, URL selectImg, URL disableImg) {
      try {
	     if(null != defaultImg) {
            defaultImage = new ImageIcon(ImageIO.read(defaultImg));
            this.setIcon(defaultImage);
	     } // END if
	     if(null != hoverImg) {
            hoverImage = new ImageIcon(ImageIO.read(hoverImg));
            this.setRolloverIcon(hoverImage);
	     } // END if
	     if(null != selectImg) {
            selectImage = new ImageIcon(ImageIO.read(selectImg));
            this.setSelectedIcon(selectImage);
	     } // END if
	     if(null != disableImg) {
            disableImage = new ImageIcon(ImageIO.read(disableImg));
            this.setDisabledIcon(disableImage);
	     } // END if
         this.setMargin(new Insets(0, 0, 0, 0));
      } catch(Exception e) {}
   } // END constructor
} // END class DynamicOmniToggleButton